package com.gouqi.tools.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gouqi.gouqitoolscommon.model.entity.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description 针对表【role(角色表)】的数据库操作Mapper
 */
public interface RoleMapper extends BaseMapper<Role> {

    @Select({"<script>", "select info FROM permission WHERE id IN ", "(SELECT permissionId FROM role_ps WHERE roleId IN (", "SELECT id FROM role WHERE NAME IN ", "<foreach collection='roles' item='name' open='(' separator=',' close=')'>", "#{name}", "</foreach>", "))", "</script>"})
    List<String> getRolePermissionsByUserAccount(@Param("roles") List<String> roles);

    @Select({"<script>", "select info FROM permission WHERE id IN ", "(SELECT permissionId FROM role_ps WHERE roleId IN (", "SELECT id FROM role WHERE NAME IN ", "<foreach collection='roles' item='name' open='(' separator=',' close=')'>", "#{name}", "</foreach>", "))", "</script>"})
    List<String> getRolePermissionsByAccessKey(@Param("roles") List<String> roles);
}




